﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace TiaoTiaoCode.Pagination.Converters
{
    [ValueConversion(typeof(bool), typeof(Visibility))]
    internal class BoolToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if(value == null)
                return Visibility.Hidden;

            var v = bool.Parse(value.ToString()!);
            if (v)
                return Visibility.Visible;

            return Visibility.Hidden;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return true;
        }
    }
}
